#include <iostream>
#include <cstdio>
#include <unistd.h>
#include <pthread.h>

void *thread_routine(void *args)
{
    std::string name = (const char*)(args);
    while (true)
    {
        std::cout << "我是新线程..., 名字: " << name << " pid: " << getpid()<< std::endl;
        sleep(1);
    }
}

int main()
{
    pthread_t tid;
    pthread_create(&tid,nullptr,thread_routine,(void*)"thread-1");

    while(true)
    {
        std::cout<<"我是主线程...,pid:"<<getpid()<<std::endl;
        sleep(1);
    }
}